Part Number Hot Search : 
05410 74AHCT1 DF2005 UPD5201C CAT5140 SMF10AG ICX259AL EMG22D
Product Description
Full Text Search
 

To Download SAP70300-B03 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  sap703000-b03 middleware for jpeg (preliminary) 1996 user's manual applicable device v850 family tm document no. u10684ej1v0um00 (1st edition) date published march 1996 p printed in japan
the information in this document is subject to change without notice. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of nec corporation. nec corporation assumes no responsibility for any errors which may appear in this document. nec corporation does not assume any liability for infringement of patents, copyrights or other intellectual p r o p e r t y r i g h t s o f t h i r d p a r t i e s b y o r a r i s i n g f r o m u s e o f a d e v i c e d e s c r i b e d h e r e i n o r a n y o t h e r l i a b i l i t y a r i s i n g from use of such device. no license, either express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec corporation or of others. v800 series, v850 family, v851, and v852 are trademarks of nec corporation. green hills software is a trademark of green hills software, inc. of the u.s.a. unix is a registered trademark of x/open company limited, licensed in the u.s.a. and other countries. windows is a trademark of microsoft corporation. sun4 is a trademark of sun microsystems, inc.
preface users this manual is aimed at those users involved in the design and development of application systems based on the v800 series. purpose the purpose of this manual is to help users to understand the functions of the m sap703000-b03. organization this manual includes the following: ? overview ? library specifications ? source lists of sample programs reading this manual the m sap703000-b03 is referred to as the ap703000-b03 throughout this manual. notation note : explanation of item indicated in the text caution : information to which the user should afford special attention remark : supplementary information numeric values : binary : xxxx or xxxxb decimal : xxxx hexadecimal : 0xxxxx units for representing powers of 2 (address space or memory space): k (kilo) : 2 10 = 1024 m (mega) : 2 20 = 1024 2 related documents the following tables list related documents. note that some documents may be preliminary editions, although this is not indicated in this manual. ? documents related to the v850 family document name data sheet users manual product name hardware architecture v851 tm ip-8971 ieu-1411 u10243e v852 tm to be determined u10038e
? documents related to development tools document name document no. ie-703000-mc users manual scheduled for release ca850 users manual operation (windows tm -based) scheduled for release operation (unix tm -based) u10553ej assembly language u10543ej c eeu-1545 id850 users manual operation (windows-based) scheduled for release installation (windows-based) scheduled for release sm850 users manual operation (windows-based) to be determined installation (windows-based) to be determined rx850 users manual to be determined az850 users manual to be determined ? documents related to tools produced by green hills software tm , inc. (ghs) for more information about ghs tools and related documents, contact: green hills software, inc. one cramberry hill telephone (617) 862-2002 lexington, ma02173 fax (617) 863-2633 usa
- i - contents chapter 1 overview ....................................................................................................................... 1 1.1 middleware ......................................................................................................... 1 1.2 jpeg ........................................................................................................................ 1 1.2.1 overview ..................................................................................................... 2 1.2.2 jpeg file format ....................................................................................... 18 1.3 outline of system ........................................................................................... 30 1.3.1 major functions .......................................................................................... 30 1.3.2 package contents ...................................................................................... 31 1.3.3 operating environment .............................................................................. 33 1.3.4 sample program ........................................................................................ 35 chapter 2 library specifications ........................................................................................... 37 2.1 function ............................................................................................................... 37 2.1.1 processing information for which parameters can be set ..................... 38 2.1.2 processing information that can be selected from a library ................ 40 2.2 details of processing .................................................................................. 41 2.2.1 compression .............................................................................................. 41 2.2.2 expansion ................................................................................................... 46 2.2.3 analysis ...................................................................................................... 51 2.3 appn marker ........................................................................................................... 56 2.4 data conversion/transfer between vram-mcu buffers .............. 57 2.4.1 vram configuration .................................................................................. 58 2.4.2 mcu buffer structure ................................................................................. 60 2.5 details of data type ...................................................................................... 64 2.5.1 jpeginfo structure .................................................................................. 64 2.5.2 structure of appinfo structure ............................................................... 75 2.6 external variables ......................................................................................... 76 2.7 details of functions ..................................................................................... 77 2.7.1 compression .............................................................................................. 77 2.7.2 expansion ................................................................................................... 79 2.7.3 analysis ...................................................................................................... 81 2.8 details of section .......................................................................................... 83 2.9 selecting a library ........................................................................................ 84 2.9.1 selecting a library during link ................................................................. 85 2.9.2 specifying an archive file ......................................................................... 87
- ii - 2.10 customize ............................................................................................................ 89 2.10.1 vram access function used during compression ................................. 89 2.10.2 vram access function used during expansion ..................................... 91 2.11 symbol name convention ............................................................................. 92 appendix a sample program source list .............................................................................. 93 appendix b constraints restricting use of huffman tables ..................................... 101
- iii - list of figures (1/2) figure no. title page 1-1. image compression/expansion ........................................................................................ 1 1-2. jpeg versions .................................................................................................................. 2 1-3. jpeg processing .............................................................................................................. 2 1-4. outline of jpeg processing ............................................................................................. 3 1-5. sampling of image ............................................................................................................ 5 1-6. matrix components ........................................................................................................... 8 1-7. distribution of frequency components ............................................................................ 8 1-8. quantized matrix and quantization .................................................................................. 9 1-9. zigzag scan and coding .................................................................................................. 10 1-10. huffman encoding ............................................................................................................. 12 1-11. example of distribution of bit length of dc/ac coefficients ......................................... 13 1-12. correct expansion cannot be performed because of bit error in jpeg file ............... 14 1-13. correct expansion can be performed due to use of restart markers ......................... 14 1-14. restart marker ................................................................................................................... 15 1-15. increase in file size caused by use of restart marker ................................................. 16 1-16. structure of appn segment .............................................................................................. 17 1-17. jpeg file format .............................................................................................................. 18 1-18. dct/reverse dct algorithm ........................................................................................... 29 1-19. memory map for sample program (with v851) ............................................................... 35 2-1. compression status transition ........................................................................................ 41 2-2. compression flow ............................................................................................................. 43 2-3. expansion status transition ............................................................................................. 46 2-4. expansion flow ................................................................................................................. 48 2-5. analysis status transition ................................................................................................ 51 2-6. analysis flow ..................................................................................................................... 53 2-7. compression when appn marker is used ...................................................................... 56 2-8. expansion when appn marker is used .......................................................................... 56 2-9. data conversion/transfer between vram-mcu buffers ............................................... 57 2-10. vram image ..................................................................................................................... 58 2-11. storing mcu into buffer .................................................................................................... 60 2-12. contents of mcu buffer .................................................................................................... 62 2-13. storing data of upper left, 2 x 2 pixels .......................................................................... 63 2-14. specifying archiver ........................................................................................................... 87 2-15. handling of archive file by linker ................................................................................... 88
- iv - list of figures (2/2) figure no. title page b-1. dht segment .................................................................................................................... 101 b-2. determining values of compressed codes ..................................................................... 103
- v - list of tables (1/2) table no. title page 1-1. sampling ratio and mcu ................................................................................................. 4 1-2. sampling ratio and block ................................................................................................. 6 1-3. values of dc/ac components and bit length ................................................................ 11 1-4. jpeg markers ................................................................................................................... 19 1-5. recommended huffman table ......................................................................................... 26 2-1. sampling ratios ................................................................................................................ 39 2-2. screen sizes ..................................................................................................................... 39 2-3. compression status .......................................................................................................... 42 2-4. compression status transition ........................................................................................ 42 2-5. user-set members ............................................................................................................ 44 2-6. return value of jpeg_compress ...................................................................................... 45 2-7. compression result information members ...................................................................... 45 2-8. expansion status .............................................................................................................. 47 2-9. expansion status transition ............................................................................................. 47 2-10. user-set members ............................................................................................................ 49 2-11. jpeg_decompress return values ..................................................................................... 50 2-12. expansion result information members .......................................................................... 50 2-13. analysis status .................................................................................................................. 52 2-14. analysis status transition ................................................................................................ 52 2-15. user-set members ............................................................................................................ 54 2-16. return value of jpeg_analysis ......................................................................................... 55 2-17. analysis result information members .............................................................................. 55 2-18. vram setting members ................................................................................................... 59 2-19. mcu buffer configuration ................................................................................................. 60 2-20. buffer definition ................................................................................................................. 61 2-21. storing data of 1 mcu (at 4:1:1) ..................................................................................... 63 2-22. data type .......................................................................................................................... 64 2-23. members of jpeginfo structure .................................................................................... 65 2-24. setting of jpeginfo structure member ......................................................................... 66 2-25. members of appinfo structure ...................................................................................... 75 2-26. external variables ............................................................................................................. 76 2-27. functions ........................................................................................................................... 77 2-28. sections used by library .................................................................................................. 83 2-29. file names of libraries ..................................................................................................... 84
- vi - list of tables (2/2) table no. title page 2-30. vram access functions required during compression ............................................... 89 2-31. vram access functions required during expansion .................................................... 91 2-32. symbol name convention ................................................................................................ 92 b-1. value and bit length of dc/ac component ................................................................... 101
1 chapter 1 overview chapter 1 overview 1.1 middleware middleware is a software group that has been tuned to fully exploit the performance of a processor. the software implements processing that is conventionally performed by hardware. the advent of high- performance risc (reduced instruction set computer) processors has spawned the concept of middleware, with which processing can be realized with rom/ram alone, without the need for dedicated hardware. nec supplies system solutions that support a wide range of user needs by providing human-machine interface and signal processing technologies in the form of middleware. 1.2 jpeg jpeg stands for joint photographic experts group, an international still image compression/expansion standard, established in 1991. this standard is laid down in documents iso/iec 10918-1 and 2. figure 1-1. image compression/expansion still image compression expansion jpeg file
2 m sap703000-b03 user's manual 1.2.1 overview there are several versions of the jpeg standard, such as progressive jpeg, in which an outline of the image appears first, detail being added subsequently. lossless jpeg can completely restore an image to the state existing before compression. these versions, however, are not in general use. the ap703000- b03 supports only the most commonly used version, called baseline dct. figure 1-2. jpeg versions (1) flow of jpeg processing jpeg compression involves compressing data in three steps: <1> dct, <2> quantization, and <3> entropy compression. jpeg expansion involves reproducing a compressed image by applying the reverse of the above procedure: <1> entropy expansion, <2> reverse quantization, and <3> reverse dct. figure 1-3. jpeg processing dct (discrete cosine transform) processing involves the disassembly of frequencies. quantization reduces the volume of information by eliminating, from the data obtained as a result of dct (i.e., data whose frequency has been disassembled), those frequency components that humans cannot sense. entropy encoding is generally known as reversible compression/expansion, while baseline dct uses a technology based on huffman encoding. the ap703000-b03 performs dct and quantization as part of the same function. similarly, entropy decoding and reverse quantization are performed as part of the same function. this increases the processing speed. compression dct quantization entropy coding reverse dct reverse quantization entropy decoding expansion image data jpeg file jpeg baseline process dct sequential huffman extended dct-based process dct sequential or progressive huffman or arithmetic coding lossless process sequential huffman or arithmetic coding
3 chapter 1 overview (2) ycbcr/rgb jpeg compresses/expands images in ycbcr color space. if the image data is not ycbcr but rgb, processing to transform the rgb data into ycbcr for compression, or that to transform ycbcr data into rgb before displaying the result of expansion, is added. the y of ycbcr is luminance (brightness index), and cb/cr is chrominance, a color difference (cb is the difference in color tone between green and blue, while cr is the difference in color tone between green and red). transformation between ycbcr and rgb can be illustrated as follows: y + 0x80 0.29900 0.58700 0.11400 r cb = C0.16874 C0.33126 0.50000 g cr 0.50000 C0.41869 C0.08131 b r 1 0 1.40200 y + 0x80 g = 1 C0.34414 C0.71414 cb b 1 1.77200 0 cr figure 1-4. outline of jpeg processing rgb display rgb-to-ycbcr transformation rgb data ycbcr-to-rgb transformation ycbcr display reverse dct ycbcr data quantization jpeg data huffman compression huffman expansion jpeg file reverse quantization dct
4 m sap703000-b03 user's manual (3) sampling and mcu the minimum unit in which jpeg processing is performed is called an mcu (minimum coded unit). the mcu is separated into y/cb/cr in units of 8 x 8 pixels, each of which is called a block. obtaining four blocks of y, one block of cb, and one block of cr from one mcu can be expressed as a sampling ratio of 4:1:1. similarly, when obtaining two blocks of y, one block of cb, and one block of cr from one mcu, the sampling ratio is said to be 4:2:2. when obtaining one block each of y, cb, and cr from one mcu, the sampling ratio is 4:4:4. table 1-1. sampling ratio and mcu mcu sampling ratio block vertical 16 pixels 4:1:1 y: 4 blocks horizontal 16 pixels (h:v = 2:2) cb: 1 block, cr: 1 block vertical 8 pixels 4:1:1 y: 4 blocks horizontal 32 pixels (h:v = 4:1) cb: 1 block, cr: 1 block vertical 8 pixels 4:2:2 y: 2 blocks horizontal 16 pixels cb: 1 block, cr: 1 block vertical 8 pixels 4:4:4 y: 1 block horizontal 8 pixels cb: 1 block, cr: 1 block although the jpeg standard covers sampling ratios other than those listed in table 1-1, the ap703000- b03 supports only those sampling ratios listed in the table. jpeg compression starts by dividing the image in this mcu units into grids. conversely, jpeg expansion involves arranging the processing result for each mcu in a manner exactly like paving a floor with tiles. for example, an image is vertically and horizontally divided into 16-pixel units, each at a sampling ratio of 4:1:1 (h:v = 2:2). next, the 16 x 16 pixel image is separated into y, cb, and cr components, and the y component is divided into four blocks, each block consisting of 8 x 8 pixels. for the cb and cr components, an 8 x 8 pixel image is created from the 16 x 16 pixel image. at this time, the vertically and horizontally adjacent 4 pixels are averaged. this is called thinning out.
5 chapter 1 overview original 16 x 16 pixel image ycbcr separation sampling sampling ratio of 4:1:1 (h:v = 2:2) original 8 x 16 pixel image ycbcr separation sampling sampling ratio of 4:2:2 original 8 x 8 pixel image ycbcr separation and sampling sampling ratio of 4:4:4 original 8 x 32 pixel image sampling ratio of 4:1:1 (h:v = 4:1) y y y y cb cb cb cb cr cr cr cr figure 1-5. sampling of image with jpeg compression, a sampling ratio of 4:1:1 is used more often than 4:4:4. at a sampling ratio of 4:1:1, the chrominance component is subjected to less processing than the luminance component. this is because the human eye is more sensitive to changes in brightness than changes in color, such that a high compression ratio can be realized by omitting that information which is difficult for the human eye to detect.
6 m sap703000-b03 user's manual as an example, lets consider the case in which an image consisting of 640 x 480 pixels is compressed. to compress this image at a sampling ratio of 4:1:1 (h:v = 2:2), it is divided by 16 pixels both horizontally and vertically, giving 40 horizontal segments and 30 vertical segments. six blocks are extracted from each mcu: four blocks of the y component, one block of the cb component, and one block of cr component. consequently, 7200 blocks (= 40 x 30 x 6) are obtained from the entire image. to these 7200 blocks, dct, quantization, and huffman compression are applied in sequence. table 1-2. sampling ratio and block sampling ratio 640 x 480 pixels number of blocks total number horizontal vertical 4:1:1 40 segments 30 segments 6 7200 (h:v = 2:2) 4:1:1 20 segments 60 segments 6 7200 (h:v = 4:1) 4:2:2 40 segments 60 segments 4 9600 4:4:4 80 segments 60 segments 3 14400 as is evident from the above table, more blocks are needed at a sampling ratio of 4:4:4 than at 4:1:1. the greater the number of blocks, the more processing time is required. moreover, the size of the resulting jpeg file also increases. in jpeg compression, processing is performed on a block-by-block basis after sampling. dct, quantization, and entropy encoding are performed based on the information to which of y or cb/cr a given block belongs. in jpeg expansion, the result is obtained in units of blocks once entropy decoding, reverse quantization, and reverse dct have been completed. per mcu of blocks
7 chapter 1 overview (4) dct dct transformation uses the following expression: dct f ( u , v ) = ss f ( i , j ) cos {} cos {} reverse dct f ( i , j ) = ss c ( u ) c ( v ) f ( u , v ) cos {} cos {} c ( w )= ( w = 0) = 1 ( w 0) generally, this dct is applied to 8 x 8 elements with signal processing techniques such as jpeg and mpeg. dct disassembles a frequency of cos ( n p /16) (where n = 0, 1, 2, ... 7) in both the vertical and horizontal directions. generally, relatively few elements of a natural image, such as a photograph, have values, the other elements tending to have values close to zero when the frequency is disassembled in this way. even by approximating those elements having a value close to zero with zero, an image close to the original can be produced by using the remaining elements. however, the differences between the original image and an image created in this way are barely visible to the human eye. 1 2 2 c ( u ) c ( v ) n C 1 n C 1 (2 i + 1) u p (2 j + 1) v p n i = 0 j = 0 2 n 2 n 2 n C 1 n C 1 (2 i + 1) u p (2 j + 1) v p n u = 0 v = 0 2 n 2 n
8 m sap703000-b03 user's manual when image data of 8 x 8 pixels is transformed by means of dct, the first element indicates the average value for the entire matrix, while the other 63 elements indicate the distortion of color in the matrix. because of the difference in nature between the first element in the matrix and the other 63 elements, the first element is called a dc (direct current) component, while the other 63 elements are called ac (alternating current) components. figure 1-6. matrix components in an 8 x 8 matrix after the application of dct, the low-frequency components are concentrated at the left and top edges, while the high-frequency components are concentrated at the right and bottom edges. if the original image exhibits few changes in tone, such as those that approach monochrome, a matrix of only low-frequency components (with almost all the high-frequency values being 0) can be obtained. conversely, with a delicate image such as a diced pattern, a matrix with several high frequencies can be obtained. figure 1-7. distribution of frequency components : dc component : ac components : dc component : ac components low frequency low frequency high frequency high frequency
9 chapter 1 overview (5) quantization and zigzag scan it is said that the human eye can barely recognize changes in high-frequency components but can easily recognize the most subtle changes in low-frequency components. to increase the compression ratio, jpeg compression divides low-frequency components by a small value and high-frequency components by a greater value. this processing is called quantization. to expand compressed data, the data is multiplied by the same value by which it was divided (reverse quantization). however, the data cannot be fully restored by applying quantization and reverse quantization (cannot be reversed). this is because, when data is quantized, only the quotient resulting from division is used as information, the remainder being ignored. in this way, the jpeg standard enables an increase in the compression ratio without visibly degrading the image. figure 1-8. quantized matrix and quantization data obtained by applying dct to a block of the original image is notable in that the data of the y component differs from that of the cb/cr component. therefore, jpeg uses two types of quantized matrixes for the y and cb/cr components, respectively (in some cases, only one quantized matrix is used). these quantized matrixes can be defined independently for each image (jpeg file). information relating to these quantized matrixes is stored as a dqt segment in the header of the jpeg file. as shown by the example in figure 1-8, if most of the values in the obtained matrix are 0, the information that there is a sequence of n zeroes followed by a value that is not zero is interpreted to increase the compression rate. the jpeg standard refers to this sequence of zeroes as the length of zero run. the non-zero values in the matrix obtained as a result of quantization gather in the upper left part of the matrix most of the time. for this reason, the length of the zero run is counted by jpeg in the sequence illustrated below (zigzag scan). example of quantized matrix example of quantized 8 x 8 matrix 8 16192226 27 2934 16 16 22 24 27 29 34 37 19 22 26 27 29 34 34 38 22 22 26 27 29 34 37 40 22 26 27 29 32 35 40 48 26 27 29 32 35 40 48 58 26 27 29 34 38 46 56 69 27 29 35 38 46 56 69 83 43 ? 0 1 0 0 0 0 ? ? 0 1 0 0 0 0 032010 00 11000 0 00 01000 0 00 00000 0 00 00000 0 00 00000 0 00 q ( i , j ) =
10 m sap703000-b03 user's manual figure 1-9. zigzag scan and coding (6) entropy encoding with baseline dct version of jpeg, entropy encoding that uses huffman coding is performed. in entropy encoding, the absolute values and distribution of the dc and ac components differ. while the absolute value of an ac component is relatively low, the absolute value of the dc component tends to be great. this is because the dc component is the average value of a given block. with jpeg, a difference between the dc component of the current block and the dc component of the preceding block is calculated for each of the y, cb, and cr components, and this difference is compressed by means of entropy when the dc component is compressed. for the ac coefficients, the combination of the length of the zero run and the value of a non-zero coefficient (level value) is compressed by means of entropy. the compressed code is called a vlc (variable length code). in jpeg compression, the dc and ac components are compressed in accordance with different huffman encoding conventions. this is referred to as the dc and ac components using different huffman tables. moreover, like quantization, because the distribution of values differs between the y and cb/cr components, separate huffman tables are usually used for the y and cb/cr components. consequently, four huffman tables are used for jpeg compression. information relating to these huffman tables can be defined by each jpeg file, and is stored as a dht segment in the jpeg file header. for entropy encoding of a certain value, an absolute value of n bits can only contain n bits of information. in other words, a value whose absolute value is n bits can be expressed using n bits. in signal processing, values are usually defined as follows: positive number consisting of n bits: lower n bits of value negative number consisting of n bits: lower n bits of value, with the sign inverted in jpeg compression, entropy encoding follows the above scheme. 439010000 84010000 03 201000 11 000000 01 000000 00 000000 00 000000 00 000000 (run, level) (0, ?) (0, ?) (1, ?) (1, 1) (1, 3) (0, ?) (1, 1) (0, 2) (0, 1) (5, 1) (5, ?) eob vlc 0000 0001 1000 1 0000 0001 1101 1 0000 0011 001 0110 0010 0101 0 111 0110 0100 0 110 0001 110 0001 111 10 0x01, 0x88, 0x0e, 0xc0, 0xcb, 0x12, 0xbb, 0x21, 0x87, 0x0f, 0x80,
11 chapter 1 overview table 1-3. values of dc/ac components and bit length value of component category 00 C1, 1 1 C3, C2, 2, 3 2 C7 to C4, 4 to 7 3 C15 to C8, 8 to 15 4 C31 to C16, 16 to 31 5 C63 to C32, 32 to 63 6 C127 to C64, 64 to 127 7 C255 to C128, 128 to 255 8 C511 to C256, 256 to 511 9 C1023 to C512, 512 to 1023 10 C2047 to C1024, 1024 to 2047 11 in jpeg compression, entropy compression of the values in this category is performed. for example, suppose the huffman table for the dc component for luminance (y) follows the convention shown below: huffman compressed code 00 (2 bits) is allocated to a value 0 bits long. huffman compressed code 010 (3 bits) is allocated to a value 1 bit long. huffman compressed code 011 (3 bits) is allocated to a value 2 bits long. huffman compressed code 100 (3 bits) is allocated to a value 3 bits long. huffman compressed code 001 (3 bits) is allocated to a value 4 bits long. . . . if the difference in the dc component of the block of the y component (difference from the dc component of the block of the preceding y component) is C3, C3 is encoded as follows, because it belongs to category 2. huffman compressed code of category 2: 011 (3 bits) lower 2 bits of C3 with sign inverted: 00 3 + 2 = 5 bits
12 m sap703000-b03 user's manual figure 1-10. huffman encoding for the ac components, the huffman table follows the convention shown below: compressed code 00 (2 bits) is allocated to a 1-bit value with a zero run of 0. compressed code 01 (2 bits) is allocated to a 2-bit value with a zero run of 0. compressed code 100 (3 bits) is allocated to a 3-bit value with a zero run of 0. compressed code 1010 (4 bits) is allocated to a 4-bit value with a zero run of 0. compressed code 1011 (4 bits) is allocated to a 1-bit value with a zero run of 1. compressed code 1100 (4 bits) is allocated to a 5-bit value with a zero run of 0. compressed code 11010 (5 bits) is allocated to a 2-bit value with a zero run of 1. . . . determined from huffman table huffman compressed code level value positive number: lower n bits of value of component negative number: lower n bits, with sign inverted (n: category)
13 chapter 1 overview figure 1-11. example of distribution of bit length of dc/ac coefficients 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 10 20 30 40 50 60 (%) (bit) (a) distribution of bit length of dc coefficient 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0102030405060 ( % ) (bit) (b) distribution of bit length of ac coefficient
14 m sap703000-b03 user's manual (7) restart marker in jpeg compression, a 2-byte marker (restart marker) is inserted in a code for compressing mcu. the restart marker can be used to expand only the lower part of a jpeg image. if a bit error occurs while a jpeg file is being transferred, and if that file uses restart markers, expansion can be correctly resumed from the next restart marker. with a jpeg file that does not use restart markers, the data cannot be correctly expanded if a bit error occurs. figure 1-12. correct expansion cannot be performed because of bit error in jpeg file figure 1-13. correct expansion can be performed due to use of restart markers
15 chapter 1 overview there are eight types of restart markers, in the value range of 0xff,0xd0 to 0xff,0xd7. a restart marker is inserted in a compressed code every m mcus, and used in the order of rst0, rst1, and rst2 to rst7. following rst7, rst0 is used. the value of m is called the restart interval. if the restart interval is 3, the image will be as shown in the figure below. figure 1-14. restart marker the number of restart markers to be inserted is determined by the size of the image. for example, the number of restart markers for an image measuring 640 x 480 pixels, for a sampling ratio of 4:2:2 and a restart interval of 2, is calculated as follows: mcu (minimum compression unit): 16 x 8 pixels restart marker: every 2 mcus therefore, (640 x 480) (16 x 8) 2 = 1200 restart markers rst0 ff, d0 rst1 ff, d1 rst2 ff, d2 rst3 ff, d3 rst4 ff, d4 rst5 ff, d5 rst6 ff, d6 rst7 ff, d7 rst0 ff, d0
16 m sap703000-b03 user's manual a restart marker is located on a byte boundary. on the other hand, compressed code is located in bit units. if one restart marker is inserted, therefore, the data quantity increases to a value equal to the marker, plus 2 bytes. the number of bytes per restart marker is usually less than 4 bytes, although it tends to vary slightly. the dc component immediately after a restart marker is compressed not as the difference from the preceding dc component, but as the value of the dc component itself. for example, the size of the file for an image measuring 640 x 480 pixels, where the sampling ratio is 4:2:2 and the restart interval is 2, increases by about 4800 bytes (1200 markers x about 4 bytes) relative to when no restart marker is used. figure 1-15. increase in file size caused by use of restart marker compressed code one mcu dc coefficient of cr component (difference) dc coefficient of cb component (difference) dc coefficient of y component (difference) restart marker inserted byte align one mcu restart marker dc coefficient of y component (absolute value) dc coefficient of cb component (absolute value) dc coefficient of cr component (absolute value)
17 chapter 1 overview (8) appn marker in jpeg compression, an application data segment (appn segment) can be used so that data not directly related to jpeg compression/expansion can be embedded in or extracted from the header of a jpeg file. there are 16 types of appn segments. the contents of these segments can be defined by the user. figure 1-16. structure of appn segment there are 16 types of appn markers, from 0xff,0xe0 to 0xff,0xef, each corresponding to an appn segment. the ap703000-b03 determines whether an appn segment is to be used during compression. when an appn segment is to be used, which of the segments is to be used is specified by selecting the corresponding appn marker. an analysis routine that detects the position of an appn segment in the jpeg file is also provided. appn marker (2 bytes) data length (2 bytes) data (1 to 65533 bytes)
18 m sap703000-b03 user's manual 1.2.2 jpeg file format a jpeg file consists of a header that contains several pieces of information necessary for expanding the file, and data obtained by means of dct, quantization, and entropy compression of an image. all the header data is in byte units (when information is analyzed, however, 1 byte is processed as 4 bits + 4 bits). data is in bit units. all data is accommodated on a byte boundary. figure 1-17. jpeg file format (1) header in jpeg compression, tables are managed in units called segments that start with a marker. a marker always consists of 2 bytes, a combination of 0xff and 1 byte unique to each marker. if a jpeg file is searched for all occurrences of 0xff, all the markers used in the file can be detected. however, 0xff is also used in the compressed data, not only in the header. to distinguish between the markers and data, therefore, 0xff in the compressed data is immediately followed by 0x00, which is meaningless as compressed data. 0xff,0x00 is not a marker, instead being compressed data 0xff. the sequence of each segment (such as com, dqt, sof, and dht) of the jpeg header is arbitrary. the following table lists the jpeg markers. data sos compressed code soi com dqt sof dht eoi jpeg header
19 chapter 1 overview table 1-4. jpeg markers value contents 0xff 0x00 non-marker (compressed data 0xff) 0xff 0x01 tem (temporary marker for arithmetic compression) 0xff 0x02 to 0xff 0xbf res (reserved) 0xff 0xc0 sof0 marker (baseline dct (huffman)) 0xff 0xc1 sof1 marker (extended sequential dct (huffman)) 0xff 0xc2 sof2 marker (progressive dct (huffman)) 0xff 0xc3 sof3 marker (spatial (sequential) lossless (huffman)) 0xff 0xc4 dht marker (huffman table definition segment) 0xff 0xc5 sof5 marker (differential sequential dct (huffman)) 0xff 0xc6 sof6 marker (differential progressive dct (huffman)) 0xff 0xc7 sof7 marker (differential spatial (huffman)) 0xff 0xc8 jpg marker (reserved for jpeg expansion) 0xff 0xc9 sof9 marker (extended sequential dct (arithmetic)) 0xff 0xca sof10 marker (progressive dct (arithmetic)) 0xff 0xcb sof11 marker (spatial (sequential) lossless (arithmetic)) 0xff 0xcc dac marker (environment setting segment for arithmetic coding) 0xff 0xcd sof12 marker (differential sequential dct (arithmetic)) 0xff 0xce sof13 marker (differential progressive dct (arithmetic)) 0xff 0xcf sof14 marker (differential spatial (arithmetic)) 0xff 0xd0 to 0xff 0xd7 rstn marker (restart marker) 0xff 0xd8 soi marker (header of jpeg file) 0xff 0xd9 eoi marker (tail of jpeg file) 0xff 0xda sos marker (header of compressed data) 0xff 0xdb dqt marker (quantization table definition) 0xff 0xdc dnl marker (number of lines definition) 0xff 0xdd dri marker (definition of restart interval) 0xff 0xde dhp marker (definition of huffman table) 0xff 0xdf exp marker (expand segment) 0xff 0xe0 to 0xff 0xef appn marker (reserved for user application) 0xff 0xf0 to 0xff 0xfd jpgn marker (reserved for jpeg expansion) 0xff 0xfe com marker (comment)
20 m sap703000-b03 user's manual (a) soi (start of image) marker this marker indicates the beginning of a jpeg file. a jpeg file always starts with this 2-byte marker. (b) eoi (end of image) marker this marker indicates the end of a jpeg file. a jpeg file always ends with this 2-byte marker. (c) dqt (define quantization table(s)) marker this marker defines a quantization table. two dqt markers, one for the normal luminance component (luminance quantization table) and the other for the chrominance component (chrominance quantization table), are supported. 0xff 0xd9 eoi 0xff 0xd8 soi dqt 0xff 0xdb lq pq tq q0 q1 q63 multiple lq byte lq: length of dqt segment pq: fixed to 0 with baseline dct tq: quantization table number (0, 1, 2, 3) q0 to q63: quantization factor (1 to 255)
21 chapter 1 overview (d) dht (define huffman table(s)) marker this marker defines a huffman table. example 00, 01, 05, 01, 01, 01, 01, 01, 01, 00, 00, 00, 00, 00, 00, 00 if l1 through l16 are as shown above, the meaning is as follows: zero 1-bit code one 2-bit code, 00 five 3-bit codes, 010, 011, 100, 101, and 110 one 4-bit code, 1110 one 5-bit code, 11110 one 6-bit code, 111110 one 7-bit code, 1111110 one 8-bit code, 11111110 one 9-bit code, 111111110 no other codes v1 through vm are the corresponding huffman codes. for example, the huffman code corresponding to compressed code 010 is v2 (in this case, 010 is the second compressed code). dht 0xff 0xc4 lh tc th v1 l16 vm l1 l2 v2 lh byte multiple lh: length of dht segment tc: 0 = dc, 1 = ac th: huffman table number (0, 1) l1 to l16: indicates how many huffman codes of i bits in length exist v1 to vm: corresponding huffman code
22 m sap703000-b03 user's manual (e) appn (reserved for application segments) marker the application data segment is a segment that can be freely used by each application. usually, this segment contains the version of the application that created a jpeg file. in some cases, a small jpeg file is contained as is. this segment can be skipped by only referring to the value of lp. appn 0xff 0xe0 lp ap1 ap2 apn 0xef lp byte lp: length of appn segment ap1 to apn: data peculiar to application
23 chapter 1 overview (f) sofn (start of frame) marker in jpeg compression, that portion of a jpeg file other than the soi marker and eoi marker is called a frame. the sofn segment specifies a quantization table number necessary for expansion. the sofn segment is also called a frame header. with jpeg, color elements such as y, cb, and cr are called components. example 0xff 0xc0, 0x00, 0x11, 0x08, 0x00, 0x90, 0x00, 0xe0, 0x03, 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01 if the contents of this segment are as shown above, the meaning will be as follows: the sampling ratio of the first component (y) is 2 x 2 and the quantization table number is 0. the sampling ratio of the second component (cb) is 1 x 1 and the quantization table number is 1. the sampling ratio of the third component (cr) is 1 x 1 and the quantization table number is 1. sof0 0xff 0xc0 lf p y xnf c1 h1 v1 c2 h2 v2 tq2 cnf tqnf tq1 hnf vnf component-spec. parameters lf: length of sof0 segment p: number of bits constituting component (8 bits are allocated to each color element for 24-bit full color compression. in this case, p = 8) y: vertical size of image (number of pixels) x: horizontal size of image (number of pixels) nf: number of components (nf = 3 in the case of ycbcr, because the number of colors is 3) cn: number of nth component hn: horizontal sampling ratio of nth component vn: vertical sampling ratio of nth component tqn: quantization table number used for nth component
24 m sap703000-b03 user's manual (g) sos (start of scan) marker the sos segment is also called a scan header. the data constituting a compressed image starts immediately after the scan header. the scan header specifies the huffman table number of the compressed data. (h) dri (define restart interval) marker and rstn (restart interval termination) marker a restart marker is used to minimize the influence of illegal data such as a communication error. a restart marker is inserted every number of mcus, as set by the dri marker. for example, to insert a marker every four mcus, restart markers are inserted sequentially, starting from rst0 and rst1 to rst7, as follows: [mcu1][mcu2][mcu3][mcu4]rst0[mcu5][mcu6][mcu7][mcu8]rst1 ... because the dc coefficient is differential information with jpeg, the preceding dc coefficient is required to expand an 8 x 8 pixel block. the dc coefficient immediately after a restart marker is a differential from 0. consequently, even if data is destroyed in mcu4, mcu5 and subsequent mcus can be correctly expanded. sos 0xff 0xda ls ns component-spec. parameters ss cs1 td1 ta1 td2 ta2 csns tans cs2 se ah al tdns ls: length of sos segment ns: specifies number of components csn: id of nth component tdn: huffman table number of dc coefficient of nth component tan: huffman table number of ac coefficient of nth component ss: fixed to 0 with baseline dct se: fixed to 63 with baseline dct ah: fixed to 0 with baseline dct al: fixed to 0 with baseline dct dri 0xff 0xdd lr ri lr: length of dri segment (4) ri: restart interval
25 chapter 1 overview (2) data although the header is stored in a file in units of bytes, data is stored in a file in units of bits (the overall data is stored in multiples of bytes). the first point to be noted concerning data is that data 0xff is immediately followed by 0x00 to distinguish it from a marker. for expansion, therefore, all occurrences of 0x00 following 0xff must be ignored. to do so, data must be read from memory 1 byte at a time, and a judgment made each time to determine whether each item of byte data is 0xff. this means that a technique to increase the speed, such as reading data from memory in blocks of 2 or 4 bytes, cannot be used. (3) huffman decoding example ff c4 00 1f 00 00 01 05 01 01 01 01 01 01 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0a 0b the huffman table segment shown above is interpreted as follows: there is no 1-bit huffman code. there is one 2-bit huffman code, 00, for which the corresponding value is 0x00. there are five 3-bit huffman codes: 010, 011, 100, 101, and 110. the corresponding values are 0x01, 0x02, 0x03, 0x04, and 0x05. there is one 4-bit huffman code, 1110, for which the corresponding value is 0x06. .... if this interpretation were to be made each time compressed image data is expanded, processing would take an excessively long time. it is also wasteful to repeat the same processing over and over again. actually, therefore, a simple table is created by analyzing the huffman table segment before starting the expansion of compressed image data. this table is referenced when the image data is expanded.
26 m sap703000-b03 user's manual (a) huffman table initialization the jpeg standard recommends the creation of the following table: table 1-5. recommended huffman table number of bits minimum value of code maximum value of code number of minimum code 1 bit undefined C1 undefined 2 bits 0x0 0x0 0x0 3 bits 0x2 0x6 0x1 4 bits 0xe 0xe 0x6 5 bits 0x1e 0x1e 0x7 6 bits 0x3e 0x3e 0x8 7 bits 0x7e 0x7e 0x9 8 bits 0xfe 0xfe 0xa 9 bits 0x1fe 0x1fe 0xb 10 bits undefined C1 undefined 11 bits undefined C1 undefined 12 bits undefined C1 undefined 13 bits undefined C1 undefined 14 bits undefined C1 undefined 15 bits undefined C1 undefined 16 bits undefined C1 undefined in the above huffman code segment, the minimum value of the 3-bit huffman code is 010 (= 0x02) while the maximum value is 110 (= 0x06). the minimum code 010 is the second (0x1) of those that follow 00. (b) decoding of dc coefficient as an example, suppose that the huffman table segment shown in table 1-5 is given. also suppose that the compressed code has the following value: 0xda 0x49 (= 1101 1010 0100 1001) first, the first bit 1 (= 0x1) of the compressed data is compared with the maximum 1-bit value of the huffman code table. 0x1 > C1 (maximum 1-bit value of table) it can be determined, therefore, that the compressed code is not a 1-bit code. next, the first 2 bits 11 (= 0x3) are compared with the maximum 2-bit value of the table.
27 chapter 1 overview 0x3 > 0x0 (maximum 2-bit value of table) therefore, the compressed data is not a 2-bit code, either. then, the first 3 bits 110 (= 0x6) are compared with the maximum 3-bit value of the table. 0x6 = 0x6 (maximum 3-bit value of table) this determines that the compressed code is 3 bits long. by using this 3-bit compressed code, the position of 110 as a huffman code must be obtained. to do this, the minimum 3-bit value 0x2 of the huffman table is subtracted from compressed code 0x6. 0x6 C 0x2 = 0x4 this means that the 3-bit compressed code is at the 0x4th position. because the minimum 3-bit code 0x2 is at the 0x1th position (if the table is referenced), the following calculation is performed: 0x4 + 0x1 = 0x5 this indicates that the compressed code is at the 0x5th code position. next, the huffman code segment is referenced. 00 01 02 03 04 05 06 07 08 09 0a 0b the value of the 0x5th position is 05. this means that the 5 bits following the compressed code are a level value. next, the decoded 3 bits, 110, are stripped from the compressed code and discarded. 0xda 0x49 (= 1101 1010 0100 1001) ? 0xd2 0x48 (= 1 1010 0100 1001) the first 5 bits are 11010 (= 0x1a). because the first sign bit in this case is 1 (indicating a positive number), the obtained value is 0x1a. this completes the decoding of the dc coefficient. (c) decoding of ac coefficient basically, the ac coefficient is decoded in the same manner as the dc coefficient, but with the following differences: ? the huffman code table is different. ? the higher 4 bits of the value taken from the huffman code segment indicate the length of the zero run, while the lower 4 bits indicate the number of bits of the level value.
28 m sap703000-b03 user's manual (4) reverse quantization reverse quantization involves multiplying the 8 x 8 pixel matrix obtained as a result of huffman decoding, by a quantized matrix defined by the quantization segment. because this processing only involves calculating the product of the two values read from memory, followed by writing the result to another memory address, processing that restores the original sequence of a zigzag scan is also performed at the same time, so that the number of times memory is accessed can be reduced and the overall processing speed improved. almost all the elements of the matrix obtained as a result of huffman decoding have a value of 0 (zero). the normal cpu requires several clocks to execute the multiplication or memory access (read or write). the ap703000-b03 inserts one expression to identify whether the value of an element is 0. if the value is 0, that element is rejected. (5) actuality of dct/reverse dct dct is equivalent to repeating the following one-dimensional calculation twice (vertically and horizontally). f ( u , v )= 2 c ( u )c( v )/n* ss f ( i , j )*cos {(2 i + 1) u p /2n} *cos {(2 j + 1) v p /2n} = 2 c ( u ) c ( v )/n* s cos {(2 i + 1) u p /2n} * s f ( i , j )*cos {(2 j + 1) v p /2n} the number of constants required for two dimensions and eight orders (n = 8; i.e., 8 x 8 matrix) is 32. actually, however, this can be decreased by applying the formulae of a trigonometric function to the subsequent seven. cos(n p /16) (n = 0, 1, 2, ... 31) ? cos (n p /16) (n = 1, 2, 3, 4, 5, 6, 7) if the following value has been calculated in advance, the number of times multiplication is executed can be reduced. f (0, j ) f (7, j ), f (1, j ) f (6, j ), ... further, the vertical and horizontal routines can be used commonly if the dct expression is changed as follows: g ( i , v ) = s f ( i , j )*cos {(2 j + 1) v p /16} f ( u , v ) = s g ( i , v )*cos {(2 i + 1) u p /16}
29 chapter 1 overview figure 1-18. dct/reverse dct algorithm actually, the pointer of f ( i , j ) and the pointer of work area g ( i , v ) are passed as arguments to the dct routine. by allocating this work area to high-speed ram, the processing speed can be increased. f ( i , j ) g ( i , v ) f ( u , v )
30 m sap703000-b03 user's manual 1.3 outline of system 1.3.1 major functions (1) sampling ratio the following four sampling ratios are supported. ? 4:1:1 [h:v = 2:2] (the screen size is a multiple of 16 both vertically and horizontally.) ? 4:1:1 [h:v = 4:1] (the screen size is a multiple of 32 horizontally, and of 8 vertically.) ? 4:2:2 [h:v = 2:1] (the screen size is a multiple of 16 horizontally, and of 8 vertically.) ? 4:4:4 [h:v = 1:1] (the screen size is a multiple of 8 both vertically and horizontally.) (2) coordinates (x, y) assuming vram specification for both ycbcr and rgb, an image can be expanded at any point in vram and can be compressed at any point in vram. (3) quantization table up to two quantization tables can be set. a default quantization table is provided for compression, but a user-defined quantization table can also be used. the value written to the dqt header is used for expansion. (4) huffman table up to four huffman tables can be set. a default huffman table is provided for compression, but a user-defined huffman table can also be used. the value written to the dht header is used for expansion. (5) restart marker whether restart markers are to be used can be specified for compression. if they are used, the restart interval can be changed. the value of the dri header is used for expansion.
31 chapter 1 overview 1.3.2 package contents the package includes the following libraries and sample source. (1) nec version nec lib850 libjpegc.a libjcs11.a libjcs21.a libjcs22.a libjcs41.a libjcy.a libjcr.a libjpegd.a libjds11.a each library libjds21.a (see section 2.9 .) libjds22.a libjds41.a libjdhb.a libjdhl.a libjdy.a libjdr.a libjpega.a libjpeg.a smpl850 jpeg start.s :start up jpeg.h :header file 1 jpegasm.h :header file 2 main.c :sample main table.c :table fish.c :sample jpeg tpycc.c :sample source (for ycbcr) tprgb.c :sample source (for rgb) getmcu.c :c getmcu sample putmcu.c :c putmcu sample makeycc :make file (for ycbcr) makergb :make file (for rgb) jpegarce.exe :for dos execution file creating jpegarc :for sun4 archive specification file dfile :link directive
32 m sap703000-b03 user's manual (2) ghs version ghs lib850 libjpegc.a libjcs11.a libjcs21.a libjcs22.a libjcs41.a libjcy.a libjcr.a libjpegd.a libjds11.a each library libjds21.a (see section 2.9 .) libjds22.a libjds41.a libjdhb.a libjdhl.a libjdy.a libjdr.a libjpega.a libjpeg.a smpl850 jpeg start.s :start up jpeg.h :header file 1 jpegasm.h :header file 2 main.c :sample main table.c :table fish.c :sample jpeg tpycc.c :sample source (for ycbcr) tprgb.c :sample source (for rgb) gemcu.c :c getmcu sample putmcu.c :c putmcu sample makeycc :make file (for ycbcr) makergb :make file (for rgb) jpegarce.exe :for dos execution file creating jpegarc :for sun4 archive specification file make.lnk :section specification each library can be re-linked. for details of how to perform link, refer to the manual supplied with the linker.
33 chapter 1 overview 1.3.3 operating environment (1) applicable cpu v850 family (2) compiler package used ghs (green hills software, inc.) compiler c cross compiler v850 ver.1.8.7b or later nec compiler package ca850 ver.1.00 or later (3) memory capacity the amount of rom/ram required for each library is as follows. however, the total differs depending on which sampling ratio is selected. when using rgb, more memory is required. rom size (units: bytes) sampling ratio base 4:4:4 4:2:2 4:1:1 4:1:1 processing [h:v = 1:1] [h:v = 2:1] [h:v = 2:2] [h:v = 4:1] compression ycbcr 5.5k 0.7k 0.7k 1.0k 1.0k rgb 0.8k 1.0k 1.5k 1.5k expansion ycbcr 4.5k 0.5k 0.5k 0.7k 0.7k rgb 0.7k 0.7k 1.1k 1.1k analysis 1.5k
34 m sap703000-b03 user's manual ram size (units: bytes) sampling ratio base 4:4:4 4:2:2 4:1:1 4:1:1 processing [h:v = 2:2] [h:v = 2:2] [h:v = 2:2] [h:v = 4:1] compression jpeginfo 128 work1 256 work2 3072 mcu 384 512 768 768 stack 128 subtotal 3584 384 512 768 768 expansion jpeginfo 128 work1 256 work2 8192 mcu 384 512 768 768 stack 128 subtotal 8704 384 512 768 768 analysis jpeginfo 128 work1 256 stack 128 subtotal 512 example the required memory size is as shown in the table below, provided conditions are as follows: ycbcr/rgb: ycbcr selected processing: compression/expansion sampling ratio: only 4:1:1 [h:v = 2:2] for both compression/expansion rom size (bytes) ram size (bytes) compression compression base + compression 4:1:1 compression base + compression mcu 4:1:1 = 5.5k + 1.0k = 3584 + 768 = 6.5k = approx. 5k expansion expansion base + expansion 4:1:1 expansion base + expansion mcu 4:1:1 = 4.5k + 0.7k = 8704 + 768 = 5.2k = approx. 10k total approx. 11.7k approx. 15k
35 chapter 1 overview 1.3.4 sample program the package includes the sources of sample programs for compression, expansion, and analysis. use these sources as system examples. for details of the sources, see appendix a . figure 1-19 shows an example of mapping the sample programs. figure 1-19. memory map for sample program (with v851) peripheral i/o area internal ram image stack area unused data having no initial value (compression, expansion, analysis) data having an initial value (compression, expansion, analysis) unused vram area unused internal rom image program (compression, expansion, analysis) conversion table data (compression, expansion, analysis) interrupt/exception vector table 0xffffff 0xfff000 0xffe400 0xffe000 0x900000 0x800000 0x300000 0x200000 0x100000 0x008000 0x000160 0x000000
36 m sap703000-b03 user's manual [memo]
37 chapter 2 library specifications chapter 2 library specifications 2.1 function the library group provided with the ap703000-b03 enables the following three types of processing to be performed: (1) compression image data is compressed and a jpeg file is created. (2) expansion the jpeg file is expanded and displayed on the screen. (3) analysis information, such as screen size, is obtained from the jpeg file. xxx.jpg analysis result jpeg analysis jpeg file library analysis buffer conversion to mcu data jpeg compression library jpeg file vram xxx.jpg conversion to data for vram jpeg expansion xxx.jpg jpeg file library vram
38 m sap703000-b03 user's manual the following two types of processing information can be set by the libraries: <1> processing information that can be set by parameters the user can set parameters in an application for the following six items: ? huffman table ? quantization table ? sampling ratio (1) ? restart marker ? screen size (horizontal, vertical) ? coordinates (x, y) <2> processing information that can be selected by the libraries the user can select parameters for the following three items from the libraries. ? sampling ratio (2) ? vram (ycbcr/rgb) ? huffman expansion procedure 2.1.1 processing information for which parameters can be set the items for which the user can set parameters in an application are as follows. for details, see section 2.5 . (1) huffman table set four huffman tables, for the dc luminance component, ac luminance component, dc chrominance component, and ac chrominance component. compression although a default table is provided, a user-defined table can also be set. expansion the value in the dht header is used. (2) quantization table set two quantization tables for the luminance and chrominance components. compression although a default table is provided, a user-defined table can also be set. a parameter called quality is also provided in a library. a defined table processed with quality specified is handled as a quantization table. expansion the value in the dqt header is used.
39 chapter 2 library specifications (3) sampling ratio (1) compression four sampling ratios are supported: 4:4:4 [h:v = 1:1], 4:2:2 [h:v = 2:1], 4:1:1 [h:v = 2:2], and 4:1:1 [h:v = 4:1]. this information is appended to the jpeg header. expansion four sampling ratios are supported: 4:4:4 [h:v = 1:1], 4:2:2 [h:v = 2:1], 4:1:1 [h:v = 2:2], and 4:1:1 [h:v = 4:1]. the sampling ratio used is automatically identified and, therefore, can be ignored by the user. table 2-1. sampling ratios sampling ratio 4:1:1 4:2:2 4:4:4 color normal fairly clear clear file size reference value (x1) about x4/3 about x2 (4) restart marker compression whether restart markers are used can be selected. to use restart markers, any value can be specified. expansion the value of the dri header is used. (5) screen size (horizontal, vertical) compression and expansion the sizes that can be set are as follows: table 2-2. screen sizes sampling ratio holizontal vertical 4:4:4 [h:v = 1:1] multiple of 8 multiple of 8 4:2:2 [h:v = 2:1] multiple of 16 multiple of 8 4:1:1 [h:v = 2:2] multiple of 16 multiple of 16 4:1:1 [h:v = 4:1] multiple of 32 multiple of 8 (6) coordinates (x, y) compression and expansion assuming that a vram specification for both ycbcr/rgb, image data can be expanded at any point in vram, and also compressed at any point in vram.
40 m sap703000-b03 user's manual 2.1.2 processing information that can be selected from a library the items that the user can select from the libraries are as follows. for details of making the selection, see section 2.9 . (1) sampling ratio (2) although the sampling ratios described in sampling ratio (1) are supported by default, libraries are provided to enable each sampling ratio to be set in detail. for example, if it is known that a sampling ratio of 4:4:4 is not necessary, selection of that library can be omitted. this function enables a slight reduction in the code size. (2) vram (ycbcr/rgb) the vram input/output portion (vram-mcu (minimum coded unit) data transfer block between buffers) can be selected from the following: default vram specifications assumed by the libraries for both ycbcr/rgb. user-created vram specifications other than the above. for details, see sections 2.4 and 2.10 . (3) huffman expansion methods which perform search starting from the point having the highest probability of statistical branch, as well as those which use a loop, are provided.
41 chapter 2 library specifications 2.2 details of processing 2.2.1 compression image data is compressed and a jpeg file is created. (1) function function name description jpeg_compressinit jpeg compression library initialization jpeg_compress jpeg compression (2) status transition the transition of the compression status is shown below. figure 2-1. compression status transition a not used <1> initialization (jpeg_compresslnit) <6> normal termination, initialization (jpeg_compresslnit) b initialized <9> abnormal termination, initialization (jpeg_compresslnit) <2> start (jpeg_compress) c compression <3> compression ends (jpeg_ok) <4> buffer save request (jpeg_cont) <7> resumption (jpeg_compress) <5> detection of error (jpeg_err) d normal termination e continue f abnormal termination <8> forced termination, initialization (jpeg_compresslnit)
42 m sap703000-b03 user's manual table 2-3. compression status status explanation a not used status in which library has never been initialized since being started, such that compression cannot be executed b initialized status in which library has been initialized, allowing compression to be executed c compressed compression execution status d normal termination status in which compression has terminated normally e continue status in which processing has been aborted because the jpeg file storage buffer has become full during compression and a request to save the contents of the buffer has been issued. compression can be continued. f abnormal termination status in which processing has been terminated because an error was detected during compression. compression cannot be continued. table 2-4. compression status transition status transition explanation function/return value <1> a C> b library initialization function: jpeg_compressinit <2> b C> c start of compression function: jpeg_compress <3> c C> d normal termination return value: jpeg_ok <4> c C> e processing aborted and request to save data in buffer is return value: jpeg_cont issued because the jpeg file storage buffer is full. <5> c C> f processing terminated because error was detected return value: jpeg_err <6> d C> b library initialization after normal termination function: jpeg_compressinit <7> e C> c compression resumption function: jpeg_compress <8> e C> b library initialization after forced termination function: jpeg_compressinit <9> f C> b library initialization after abnormal termination function: jpeg_compressinit others transition impossible none
43 chapter 2 library specifications (3) processing flow the following figure shows the flow of application processing using the compression library. figure 2-2. compression flow user application library start <1> sets compression parameter <2> calls compression initialization function initializes compression library <3> calls compression function <5> buffer save processing compression <4> checks return value end jpeg_compresslnit jpeg_compress jpeg_cont jpeg_ok/ jpeg_err
44 m sap703000-b03 user's manual <1> setting compression parameter define variables having jpeginfo type structure, as defined by header file jpeg.h, and set members (see section 2.5.1 ). when executing new compression, the members must be set first. when continuing processing, the members need not be set again. subsequently, do not set parameters. table 2-5. user-set members member data to be set quality quantization factor sampling sampling ratio restart restart interval width horizontal size of compressed image height vertical size of compressed image startx start x coordinate of compressed image starty start y coordinate of compressed image vram_bptr first address of vram vram_w_pixel number of pixels in horizontal direction vram_h_pixel number of pixels in vertical direction vram_line_byte number of bytes equivalent to vram address difference of 1 pixel in vertical direction vram_pixel_byte number of bytes equivalent to vram address difference of 1 pixel in horizontal direction vram_gap1_byte number of bytes equivalent to vram address difference of y/cb or r/g component of same pixel vram_gap2_byte number of bytes equivalent to vram address difference of y/cr or r/b component of same pixel jpeg_buff_bptr first address of jpeg file storage buffer jpeg_buff_eptr end address of jpeg file storage buffer mcu_buff_bptr first address of mcu buffer dqt_y_bptr first address of quantization table for luminance component dqt_c_bptr first address of quantization table for chrominance component dht_dc_y_bptr first address of huffman table for dc luminance component dht_dc_c_bptr first address of huffman table for dc chrominance component dht_ac_y_bptr first address of huffman table for ac luminance component dht_ac_c_bptr first address of huffman table for ac chrominance component app_info_bptr when appn marker is supported: first address of appinfo structure variable when appn marker is not supported: 0 work1_bptr first address of buffer for library work area work2_bptr first address of buffer for library work area
45 chapter 2 library specifications <2> calling compression initialization function [jpeg_compressinit] call the compression initialization function by using the pointer to the structure set in <1> , above, as an argument. this function initializes the data required for compression and sets the compression library to an executable status. call this function first when executing new compression. when continuing compression, this function need not be called. <3> calling compression function [jpeg_compress] call the compression function by using the pointer to the structure set in <2> , above, as an argument. <4> checking return value [jpeg_ok/jpeg_err/jpeg_cont] the return value of jpeg_compress is as follows: table 2-6. return value of jpeg_compress return value meaning explanation jpeg_ok normal termination compression terminated normally. start from <1> again to execute new compression. jpeg_err abnormal termination processing aborted because error was detected. error details are stored in member errorstate of jpeginfo structure. start from <1> again to execute new compression. jpeg_cont continue processing has been stopped because specified jpeg file storage buffer is full. start from <1> again to forcibly terminate processing and execute new compression. to continue, execute <5> buffer save processing and start from <3> again. table 2-7. compression result information members member data to be stored errorstate error status filesize jpeg file size <5> buffer save processing save the contents of the jpeg file storage buffer.
46 m sap703000-b03 user's manual 2.2.2 expansion expansion involves expanding the jpeg file and displaying it on the screen. (1) function function name description jpeg_decompressinit jpeg expansion library initialization jpeg_decompress jpeg expansion (2) status transition the status transition during expansion is illustrated below. figure 2-3. expansion status transition a not used <1> initialization (jpeg_decompresslnit) <6> normal termination, initialization (jpeg_decompresslnit) b initialized <9> abnormal termination, initialization (jpeg_decompresslnit) <2> start (jpeg_decompress) c expansion <3> expansion terminated (jpeg_ok) <4> buffer update request (jpeg_cont) <7> resumption (jpeg_decompress) <5> detection of error (jpeg_err) d normal termination e continue f abnormal termination <8> forced termination, initialization (jpeg_decompresslnit)
47 chapter 2 library specifications table 2-8. expansion status status explanation a not used status in which library has never been initialized since start and expansion cannot be executed b initialized status in which library has been initialized and expansion can be executed c expansion expansion execution status d normal termination status in which expansion has been terminated normally e continue status in which expansion in buffer to which jpeg file has been stored has been terminated, but processing has been aborted because jpeg file end code cannot be found, causing buffer update request to be issued. expansion can be continued. f abnormal termination status in which processing has been terminated because error was detected during expansion. expansion cannot be continued. table 2-9. expansion status transition status transition explanation function/return value <1> a C> b library initialization function: jpeg_decompressinit <2> b C> c start of expansion function: jpeg_decompress <3> c C> d normal termination return value: jpeg_ok <4> c C> e data in jpeg file storage buffer has been expanded but return value: jpeg_cont jpeg file end code cannot be found. therefore, processing has been aborted and updating of data in the buffer has been requested. <5> c C> f processing terminated because error was detected return value: jpeg_err <6> d C> b library initialization after normal termination function: jpeg_decompressinit <7> e C> c resumption of expansion function: jpeg_decompress <8> e C> b library initialization after forced termination function: jpeg_decompressinit <9> f C> b library initialization after abnormal termination function: jpeg_decompressinit others transition impossible none
48 m sap703000-b03 user's manual (3) processing flow the following figure illustrates the flow of processing of an application that uses the expansion library. figure 2-4. expansion flow user application library start <1> sets expansion parameter <2> calls expansion initialization function initializes expansion library <3> calls loading expansion <5> checks return value end jpeg_decompresslnit jpeg_decompress jpeg_cont jpeg_ok/ jpeg_err <4> calls expansion processing function
49 chapter 2 library specifications <1> setting expansion parameters define the variable of the jpeginfo structure defined by header file jpeg.h and set members (see section 2.5.1 ). the members must be set when executing new expansion. when continuing expansion, the members need not be set again. subsequently, do not set parameters. table 2-10. user-set members member data to be set startx start x coordinate of expanded image starty start y coordinate of expanded image vram_bptr first address in vram vram_w_pixel number of pixels in horizontal direction vram_h_pixel number of pixels in vertical direction vram_line_byte number of bytes equivalent to vram address differing by one pixel in vertical direction vram_pixel_byte number of bytes equivalent to vram address differing by one pixel in horizontal direction vram_gap1_byte number of bytes equivalent to vram address difference of y/cb or r/g component for same pixel vram_gap2_byte number of bytes equivalent to vram address difference of y/cr or r/b component for same pixel jpeg_buff_bptr first address of jpeg file storage buffer jpeg_buff_eptr end address of jpeg file storage buffer mcu_buff_bptr first address of mcu buffer app_info_bptr 0 work1_bptr first address of library work area buffer work2_bptr first address of library work area buffer <2> calling expansion initialization function [jpeg_decompressinit] call the expansion initialization function by using the pointer to the structure defined in <1> , above, as an argument. this function initializes the data required for expansion and sets the expansion library to executable status. call this function first when executing new expansion. when continuing expansion, this function need not be called. <3> buffer loading (updating) processing load data into the jpeg file storage buffer and update it. <4> calling expansion function [jpeg_decompress] call the expansion function by using the pointer to the structure used in <2> as an argument.
50 m sap703000-b03 user's manual <5> checking return value [jpeg_ok/jpeg_err/jpeg_cont] the return value of jpeg_decompress is as follows: table 2-11. jpeg_decompress return values return value meaning explanation jpeg_ok normal termination expansion has terminated normally. start from <1> again to execute new expansion. jpeg_err abnormal termination processing terminated because an error occurred. details of the error are stored in the member of jpeginfo structure errorstate. start from <1> again to execute new expansion. jpeg_cont continue processing terminated because jpeg file end code cannot be found after expansion in the specified jpeg file storage buffer. to forcibly terminate and execute new expansion, start from <1> again. to continue, execute <3> buffer update processing, then start from <4> again. table 2-12. expansion result information members member data to be stored errorstate error status filesize jpeg file size sampling sampling ratio restart restart interval width horizontal size of image height vertical size of image
51 chapter 2 library specifications 2.2.3 analysis analysis analyzes the jpeg file and obtains the following data: <1> sampling ratio <2> restart interval <3> size of image (horizontal/vertical) <4> jpeg file size <5> application data (app data) (1) function function name description jpeg_analysisinit jpeg analysis library initialization jpeg_analysis jpeg analysis (2) status transition the following figure illustrates the status transition during analysis. figure 2-5. analysis status transition a not used <1> initialization (jpeg_analysislnit) <6> normal termination, initialization (jpeg_analysislnit) b initialized <9> abnormal termination, initialization (jpeg_analysislnit) <2> start (jpeg_analysis) c analysis <3> analysis terminated (jpeg_ok) <4> buffer updating request (jpeg_cont) <7> resumption (jpeg_analysis) <5> detection of error (jpeg_err) d normal termination e continue f abnormal termination <8> forced termination, initialization (jpeg_analysislnit)
52 m sap703000-b03 user's manual table 2-13. analysis status status explanation a not used status in which library has never been initialized since start and analysis cannot be executed b initialized status in which library has been initialized and analysis can be executed c expansion analysis execution status d normal termination status in which analysis has been terminated normally e continue status in which analysis in buffer to which jpeg file has been stored has been terminated, but processing has been aborted because jpeg file end code cannot be found, causing buffer update request to be issued. analysis can be continued. f abnormal termination status in which processing has been terminated because error was detected during analysis. analysis cannot be continued. table 2-14. analysis status transition status transition explanation function/return value <1> a C> b library initialization function: jpeg_analysisinit <2> b C> c start of analysis function: jpeg_analysis <3> c C> d normal termination return value: jpeg_ok <4> c C> e data in jpeg file storage buffer has been analyzed but return value: jpeg_cont end code of jpeg file cannot be found. therefore, processing is aborted and updating of the data in the buffer has been requested. <5> c C> f processing terminated because error was detected return value: jpeg_err <6> d C> b library initialization after normal termination function: jpeg_analysisinit <7> e C> c resumption of analysis function: jpeg_analysis <8> e C> b library initialization after forced termination function: jpeg_analysisinit <9> f C> b library initialization after abnormal termination function: jpeg_analysisinit others transition impossible none
53 chapter 2 library specifications (3) processing flow the following figure illustrates the flow of processing of an application that uses the analysis library. figure 2-6. analysis flow user application library start <1> sets analysis parameter <2> calls analysis initialization function initializes analysis library <3> buffer loading analysis <5> checks return value end jpeg_analysislnit jpeg_analysis jpeg_cont jpeg_ok/ jpeg_err <4> calls analysis function processing
54 m sap703000-b03 user's manual <1> setting of analysis parameters define the variable of the jpeginfo structure defined by header file jpeg.h and set members (see section 2.5.1 ). the members must be set to execute new analysis. when continuing analysis, the members need not be set again. subsequently, do not set parameters. table 2-15. user-set members member data to be set jpeg_buff_bptr first address of jpeg file storage buffer jpeg_buff_eptr end address of jpeg file storage buffer app_lnfo_bptr when appn marker is supported: first address of appinfo structure variable when appn marker is not supported: 0 work1_bptr first address of library work area buffer <2> calling analysis initialization function [jpeg_analysisinit] call the analysis initialization function by using the pointer to the structure defined in <1> , above, as an argument. this function initializes the data required for analysis and sets the analysis library to executable status. call this function first when executing new analysis. when continuing analysis, this function need not be called. <3> buffer loading (updating) processing load data into the jpeg file storage buffer and update it. <4> calling analysis function [jpeg_analysis] call the analysis function by using the pointer to the structure used in <2> as an argument.
55 chapter 2 library specifications <5> checking return value [jpeg_ok/jpeg_err/jpeg_cont] the return value of jpeg_analysis is as follows: table 2-16. return value of jpeg_analysis return value meaning explanation jpeg_ok normal termination analysis has been terminated normally. start from <1> again to execute new analysis. jpeg_err abnormal termination processing has been terminated because an error occurred. details of the error are stored in jpeginfo structure member errorstate. start from <1> again to execute new analysis. jpeg_cont continue processing has been terminated because the jpeg file end code cannot be found after analysis in a specified jpeg file storage buffer was completed. to forcibly terminate and execute new analysis, start from <1> again. to continue, execute <3> buffer updating processing, then start from <4> again. table 2-17. analysis result information members member data to be stored errorstate error status sampling sampling ratio restart restart interval width horizontal size of image height vertical size of image filesize jpeg file size app_info_bptr the address and data size of an appn marker are stored to a member of a specified appinfo structure variable only when the address of the appinfo structure variable is set in this member when initial parameters are set.
56 m sap703000-b03 user's manual 2.3 appn marker the processing sequences when the appn marker is supported are shown below. (1) compression the flow of the processing of an application that uses the compression library when the appn marker is supported is shown below. figure 2-7. compression when appn marker is used (2) expansion the flow of the processing of an application that uses the expansion library when the appn marker is supported is shown below. figure 2-8. expansion when appn marker is used start <1> create app data <2> compression end <1> creating app data define the variable of the appinfo structure defined by header file "jpeg.h" by using the app data and set members. for details, see section 2.5.2 . <2> compression for details, see section 2.2.1 . start <1> analysis supporting app <2> expansion <1> analysis supporting app for details, see section 2.2.3 . <2> expansion for details, see section 2.2.2 . <3> app processing perform processing supporting the appn marker based on the data stored in the appinfo structure variable in <1> , above. <3> app processing end
57 chapter 2 library specifications (3) analysis for details of how to use the analysis library when the appn marker is supported, see section 2.2.3 . 2.4 data conversion/transfer between vram-mcu buffers the following figure outlines the processing performed for the library. figure 2-9. data conversion/transfer between vram-mcu buffers with jpeg compression, the mcu is the basic unit of processing (for details of the mcu, see section 2.4.2 ). compression involves conversion from vram data to mcu, while expansion involves conversion from mcu to vram data. the library provides functions for converting or transferring data between the vram-mcu buffers in mcu units by default. the user can create his or her own functions by using these conversion routines (such as when a monochrome image is to be displayed). for details, see section 2.10 . conversion to mcu data jpeg compression library jpeg file vram xxx.jpg (a) compression conversion to vram data jpeg expansion xxx.jpg jpeg file library vram (b) expansion
58 m sap703000-b03 user's manual 2.4.1 vram configuration the vram configuration assumed by the library (default conversion routine) is shown below. ? both y/cb/cr and r/g/b are continuous ? can be accessed in byte units ? 24-bit full color figure 2-10. vram image the members of the jpeginfo structure shown in table 2-18 must be set. for details of the jpeginfo structure, see section 2.5.1 . y cb cr y cb ? ? y cb cr y cb ? ? y cb cr y cb ? ? y cb cr y cb ? ? remarks 1. data is input/output in block (mcu) units in the horizontal direction. 2. : 1 pixel (a) ycbcr r g b r g ? r g b r g ? r g b r g ? r g b r g ? (b) rgb
59 chapter 2 library specifications table 2-18. vram setting members member explanation vram_w_pixel number of pixels in horizontal direction of assumed image vram_h_pixel number of pixels in vertical direction of assumed image vram_line_byte number of bytes equivalent to vram address difference of one pixel in vertical direction vram_pixel_byte number of bytes equivalent to vram address difference of one pixel in horizontal direction vram_gap1_byte ycbcr: number of bytes equivalent to vram address difference of y and cb components of same pixel rgb: number of bytes equivalent to vram address difference of r and g components of same pixel vram_gap2_byte ycbcr: number of bytes equivalent to vram address difference of y and cr components of same pixel rgb: number of bytes equivalent to vram address difference of r and b components of same pixel setting example [vram specification] [setting member of jpeginfo structure variable] number of horizontal pixels of assumed image : 320 x .vram_w_pixel = 320 ; number of vertical pixels of assumed image : 240 x .vram_h_pixel = 240 ; number of horizontal bytes of vram : 0x3c0 x .vram_line_byte = 0x3c0 ; mode : ycbcr x .vram_pixel_byte = 3 ; 1 pixel : 3 bytes x .vram_gap1_byte = 1 ; y = cb = cr = 1 byte/continuous x .vram_gap2_byte = 2 ; jpeginfo structure variable : x C>
60 m sap703000-b03 user's manual 2.4.2 mcu buffer structure when using the jpeg library (compression/expansion), the user must prepare an mcu buffer to store data. the mcu buffer stores data sampled in mcu units when compression is executed. dct processing is performed on the stored data. if the vram is of rgb type, data is converted to ycbcr type and then stored. when expansion is executed, the result of reverse dct processing is output in mcu units. the configuration of the mcu buffer is as follows: table 2-19. mcu buffer configuration declaration size (bytes) sampling ratio short name [3] [64] 384 only 4:4:4 supported short name [4] [64] 512 up to 4:2:2 supported short name [6] [64] 768 up to 4:1:1 supported configure the buffer in the following manner: (1) define the entity in the application and pass the pointer to the member of the jpeginfo structure variable. for details of the jpeginfo structure, see section 2.5 . (2) the data is 8 bits long. it must be declared as being of short type (16 bits), however, because the data is used internally as a work buffer. (3) specify any name for name . (4) a buffer must be prepared for each jpeginfo structure variable. store each mcu into the buffer as shown below. figure 2-11. storing mcu into buffer y component 1st block y component 2nd block y component 3rd block y component 4th block cb component block cr component block (a) 4:1:1 y component 1st block y component 2nd block cb component block cr component block (b) 4:2:2 y component block cb component block cr component block (c) 4:4:4
61 chapter 2 library specifications define the following buffer. table 2-20. buffer definition processing required size compression buffer supporting compression sampling ratio. example when executing compression at a sampling ratio of 4:2:2, regardless of the supported library, define name [4] [64] as the buffer. expansion, analysis define buffer with maximum size of supported library. example if library supports sampling ratios of 4:4:4 and 4:2:2, define name [4] [64] as buffer. the contents of the buffer are shown below.
62 m sap703000-b03 user's manual figure 2-12. contents of mcu buffer 0 1 7 89 (a) 4:4:4 name [0] [ ] y (b) 4:2:2 0 1 7 89 name [1] [ ] cb 0 1 7 89 name [2] [ ] cr 0 1 7 89 name [0] [ ] y0 0 1 7 89 name [2] [ ] cb 0 1 7 89 name [3] [ ] cr (c) 4:1:1 [h:v = 2:2] 0 1 7 89 name [0] [ ] y0 0 1 7 89 name [4] [ ] cb 0 1 7 89 name [5] [ ] cr 0 1 7 89 name [0] [ ] y0 0 1 7 89 name [4] [ ] cb 0 1 7 89 name [5] [ ] cr name [1] [ ] y1 name [1] [ ] y1 name [2] [ ] y2 name [3] [ ] y3 name [1] [ ] y1 name [2] [ ] y2 name [3] [ ] y3 (d) 4:1:1 [h:v = 4:1] remark 0, 1, ... : value of second element of matrix for mcu buffer
63 chapter 2 library specifications an example where the mcu buffer is defined as buff [6] [64] at a sampling ratio of 4:1:1 is shown below. table 2-21. storing data of 1 mcu (at 4:1:1) matrix data stored buff [0] [ ] y component (upper left, 8 x 8 pixels) buff [1] [ ] y component (upper right, 8 x 8 pixels) buff [2] [ ] y component (upper left, 8 x 8 pixels) buff [3] [ ] y component (lower right, 8 x 8 pixels) buff [4] [ ] cb component (16 x 16 pixels: however, average of 2 x 2 pixels for one element) buff [5] [ ] cr component (16 x 16 pixels: however, average of 2 x 2 pixels for one element) figure 2-13. storing data of upper left, 2 x 2 pixels <1> <2> <3> <4> buff [0] [ ] y0 <5> buff [4] [ ] cb <6> buff [5] [ ] cr buff [1] [ ] y1 buff [2] [ ] y2 buff [3] [ ] y3 component storage position y component <1> buff [0] [0], <2> buff [0] [1], <3> buff [0] [8], <4> buff [0] [9] cb component <5> buff [4] [0] cr component <6> buff [5] [0]
64 m sap703000-b03 user's manual 2.5 details of data type there are two data types, as shown in table 2-22. declare all the variables of these structures, and the variables that pass an address to a member, as external variables. table 2-22. data type classification data type name data type description common jpeginfo structure compression, expansion, analysis parameter setting appinfo structure appn marker information saving 2.5.1 jpeginfo structure the member configuration of the jpeginfo structure is shown in the table below. this same structure is used for jpeg compression, expansion, and analysis processing.
65 chapter 2 library specifications table 2-23. members of jpeginfo structure member type bytes explanation errorstate long 4 error status filesize long 4 jpeg file size quality char 1 quantization factor sampling char 1 sampling ratio restart ushort 2 restart interval width ushort 2 horizontal size of image height ushort 2 vertical size of image startx ushort 2 processing start x coordinate (for assumed image) starty ushort 2 processing start y coordinate (for assumed image) currentx ushort 2 current x coordinate (for assumed image) currenty ushort 2 current y coordinate (for assumed image) vram_bptr uchar* 4 vram first address vram_w_pixel ushort 2 number of pixels in horizontal direction of assumed image vram_h_pixel ushort 2 number of pixels in vertical direction of assumed image vram_line_byte short 2 number of bytes equivalent to vram address difference of one pixel in vertical direction vram_pixel_byte short 2 number of bytes equivalent to vram address difference of one pixel in horizontal direction vram_gap1_byte short 2 number of bytes equivalent to vram address difference of ycb or rg vram_gap2_byte short 2 number of bytes equivalent to vram address difference of ycr or rb jpeg_buff_bptr uchar* 4 first address of jpeg file storage buffer jpeg_buff_eptr uchar* 4 end address of jpeg file storage buffer mcu_buff_bptr short* 4 first address of mcu buffer rgb_buff_bptr short* 4 first address of rgb buffer dqt_y_bptr char* 4 first address of quantization table (for luminance component) dqt_c_bptr char* 4 first address of quantization table (for chrominance component) dht_dc_y_bptr char* 4 first address of huffman table (for dc luminance component) dht_dc_c_bptr char* 4 first address of huffman table (for dc chrominance component) dht_ac_y_bptr char* 4 first address of huffman table (for ac luminance component) dht_ac_c_bptr char* 4 first address of huffman table (for ac chrominance component) app_info_bptr appinfo* 4 first address of appinfo structure variable work1_bptr long* 4 first address of library work area 1 work2_bptr long* 4 first address of library work area 2 work3 char 36 library work area 3 remark uchar: unsigned char, ushort: unsigned short
66 m sap703000-b03 user's manual table 2-24. setting of jpeginfo structure member member compression expansion analysis user setting in/out user setting in/out user setting in/out errorstate x out x out x out filesize x out x out x out quality o in x reserved field x reserved field sampling o in x out x out restart o in x out x out width o in x out x out height o in x out x out startx o in o in x reserved field starty o in o in x reserved field currentx x reserved field x reserved field x reserved field currenty x reserved field x reserved field x reserved field vram_bptr o in o in x reserved field vram_w_pixel o in o in x reserved field vram_h_pixel o in o in x reserved field vram_line_byte o in o in x reserved field vram_pixel_byte o in o in x reserved field vram_gap1_byte o in o in x reserved field vram_gap2_byte o in o in x reserved field jpeg_buff_bptr o in o in o in jpeg_buff_eptr o in o in o in mcu_buff_bptr o in o in x reserved field rgb_buff_bptr x reserved field x reserved field x reserved field dqt_y_bptr o in x reserved field x reserved field dqt_c_bptr o in x reserved field x reserved field dht_dc_y_bptr o in x reserved field x reserved field dht_dc_c_bptr o in x reserved field x reserved field dht_ac_y_bptr o in x reserved field x reserved field dht_ac_c_bptr o in x reserved field x reserved field app_info_bptr o in o in o in work1_bptr o in o in o in work2_bptr o in o in x reserved field work3 x reserved field x reserved field x reserved field
67 chapter 2 library specifications remark o: must be set by the user. x: must not be set by the user. because these members are used by the library, the user must never attempt to set them. in: must be set by the user. out: library sets value (return value). reserved field: reserved for library [in] indicates <1> in the figure below, while [out] indicates <4> because of the specifications of the library. user application referencing out is meaningless in <2> because the initialization function does not return a value (see section 2.7 ). in must not be set by the user in <3> because setting by the user is prohibited (see section 2.2 ). jpeg_compresslnit jpeg_decompresslnit jpeg_analysislnit jpeg_compress jpeg_decompress jpeg_analysis <1> <2> <3> <4>
68 m sap703000-b03 user's manual next, the details of each member are described. (1) errorstate classification explanation compression stores error status. expansion analysis for details of the error status, see section 2.7 . (2) filesize classification explanation compression stores size of jpeg file. expansion analysis (3) quality classification value explanation compression 0 to 100 set quantization factor. expansion C reserved field analysis the quantization factor is used to perform processing on a defined quantization table. by setting this factor appropriately, the quality of the image can be adjusted. quantization factor 0 75 100 status of image mosaic normal clear compression rate high recommended value low the lower the value of the factor, the smaller the size of the jpeg file created, but the more pronounced the mosaic effect. the higher the value, the finer the image, but the larger the size of the jpeg file created. if the quantization factor is 75, the same table is created both before and after processing. it is therefore recommended that the coefficient be set to 75.
69 chapter 2 library specifications (4) sampling classification value explanation compression sample11 set sampling ratio. sample21 four sampling ratios are supported. this information is appended to the sample22 jpeg header. sample41 expansion sample11 sampling ratio is automatically stored from jpeg file. four sampling ratios sample21 are supported. because the expansion library automatically identifies the sample22 sampling ratio being used, the user does not have to consider the sampling sample41 ratio. analysis higher 4 bits: sampling ratio is automatically stored from jpeg file. [0x1 to 0x4] lower 4 bits: [0x1 to 0x4] samplen is defined by header file jpeg.h for compression/expansion. sampling sample22 sample21 sample11 (sampling ratio) (4:1:1[h:v = 2:2]) (4:2:2[h:v = 2:1]) (4:4:4[h:v = 1:1]) color normal fairly clear clear file size reference value (x1) about x4/3 about x2 (5) restart classification value explanation compression 0 to 65535 set value of restart interval. value restart interval explanation 0 none dri header/rstn marker is not inserted. other than 0 provided inserts rstn marker for each specified mcu. expansion 0 to 65535 value of restart interval is automatically stored from jpeg file. analysis value restart interval explanation 0 none dri header/rstn marker is not included. other than 0 provided rstn marker is inserted for each specified mcu.
70 m sap703000-b03 user's manual (6) width, height classification value explanation compression 0 to 65535 set horizontal/vertical size of image to be compressed. (conditional) expansion 0 to 65535 horizontal/vertical size of compressed image is automatically stored from (conditional) jpeg file. analysis 0 to 65535 the value is limited as follows, depending on the sampling ratio, for compression/expansion. sampling ratio width (horizontal value) height (vertical value) 4:4:4 [h:v = 1:1] multiple of 8 multiple of 8 4:2:2 [h:v = 2:2] multiple of 16 multiple of 8 4:1:1 [h:v = 2:2] multiple of 16 multiple of 16 4:1:1 [h:v = 4:1] multiple of 32 multiple of 8 (7) startx, starty classification value explanation compression 0 to 32767 set start coordinates (x, y) of image to be compressed. expansion 0 to 32767 set start coordinates (x, y) of image to be expanded. analysis C reserved field (8) currentx, currenty classification explanation compression current coordinates are stored. expansion analysis reserved field user reference is limited as follows depending on how the library is used. applicable library usage user reference jpeg_getmcu_ xx default prohibited jpeg_putmcu_ xx user-created reference is permitted in each function only. for details of jpeg_getmcu_ xx and jpeg_putmcu_ xx , see sections 2.4 and 2.10 .
71 chapter 2 library specifications (9) vram_bptr classification explanation compression specify first address of vram. expansion analysis reserved field (10) vram_w_pixel, vram_h_pixel, vram_line_byte, vram_pixel_byte, vram_gap1_byte, vram_gap2_byte classification explanation compression set specifications of image to be assumed. expansion analysis reserved field the contents to be set are as follows: member explanation vram_w_pixel number of pixels in horizontal direction vram_h_pixel number of pixels in vertical direction vram_line_byte number of bytes equivalent to vram address difference of one pixel in vertical direction vram_pixel_byte number of bytes equivalent to vram address difference of one pixel in horizontal direction vram_gap1_byte ycbcr: number of bytes equivalent to vram address difference of y and cb components of same pixel rgb: number of bytes equivalent to vram address difference of r and g components of same pixel vram_gap2_byte ycbcr: number of bytes equivalent to vram address difference of y and cr components of same pixel rgb: number of bytes equivalent to vram address difference of r and g components of same pixel (11) jpeg_buff_bptr classification explanation compression specify first address of jpeg file storage buffer. expansion analysis
72 m sap703000-b03 user's manual (12) jpeg_buff_eptr classification explanation compression set end address of buffer specified by member jpeg_buff_bptr. expansion analysis (13) mcu_buff_bptr classification explanation compression set first address of mcu buffer. expansion analysis reserved field (14) rgb_buff_bptr classification explanation compression reserved field expansion analysis (15) dqt_y_bptr, dqt_c_bptr classification explanation compression specify first address of quantization table. expansion reserved field analysis the specified quantization table is as follows: member explanation dqt_y_bptr for luminance component dqt_c_bptr for chrominance component end address = first address + buffer size. for details, see section 2.4.2 .
73 chapter 2 library specifications (16) dht_dc_y_bptr, dht_dc_c_bptr, dht_ac_y_bptr, dht_ac_c_bptr classification explanation compression specify first address of huffman table. expansion reserved field analysis the specified quantization table is as follows: member explanation dht_dc_y_bptr for dc luminance component dht_dc_c_bptr for dc chrominance component dht_ac_y_bptr for ac luminance component dht_ac_c_bptr for ac chrominance component (17) app_info_bptr classification explanation compression set as follows: appn marker setting supported specify first address of appinfo structure variable. not supported set 0. expansion set 0. analysis set as follows: appn marker setting supported specify first address of appinfo structure variable. not supported set 0. for the details of the appinfo structure, see section 2.5.2 .
74 m sap703000-b03 user's manual (18) work1_bptr classification explanation compression declare the buffer as being of long type: 256 bytes for the library work area, expansion analysis locating this buffer in internal ram will result in an increase in the processing speed of the library. (19) work2_bptr classification explanation compression declare a buffer of the following size as being of long type for the library work area, and specify the first address of the buffer. expansion compression expansion size (bytes) 3072 8192 analysis reserved field (20) work3 classification explanation compression fixed work area of library. expansion analysis and specify the first address of the buffer.
75 chapter 2 library specifications 2.5.2 structure of appinfo structure the member configuration of the appinfo structure is shown below. this structure is commonly used for jpeg compression/analysis, provided the appn marker is supported. table 2-25. members of appinfo structure member type bytes explanation app00_buff_bptr uchar* 4 first address of app0 data app15_buff_bptr uchar* 4 first address of app15 data app00_buffsize ushort 2 length of app0 data app15_buffsize ushort 2 length of app15 data each of these members is described in detail below. (1) appn_buff_bptr compression analysis user setting required prohibited in/out in out compression analysis used [appn] note 1 note 3 not used [appn] note 2 note 4 notes 1. declare a data storage buffer, store data into the buffer, and specify the first address of the buffer in the corresponding member. 2. specify 0 for the corresponding member. 3. the address of the appn marker (absolute address of the jpeg file) is stored in the corresponding member. 4. 0 is stored in the corresponding member.
76 m sap703000-b03 user's manual (2) appn_buffsize compression analysis user setting required prohibited in/out in out compression analysis used [appn] note 1 note 3 not used [appn] note 2 note 4 notes 1. set a data size for the corresponding member. 2. specify 0 for the corresponding member. 3. the length of the appn segment is stored in the corresponding member. 4. 0 is stored in the corresponding member. 2.6 external variables the following external variables are provided. table 2-26. external variables external variable type size (bytes) explanation jpeg_dqt_y char 64 quantization table (for luminance component) jpeg_dqt_c char 64 quantization table (for chrominance component) jpeg_dht_dc_y char about 50 huffman table (for dc luminance component) jpeg_dht_dc_c char about 50 huffman table (for dc chrominance component) jpeg_dht_ac_y char about 300 huffman table (for ac luminance component) jpeg_dht_ac_c char about 300 huffman table (for ac chrominance component)
77 chapter 2 library specifications 2.7 details of functions the following functions are provided. table 2-27. functions classification function name description compression jpeg_compressinit jpeg compression library initialization jpeg_compress jpeg compression, main expansion jpeg_decompressinit jpeg expansion library initialization jpeg_decompress jpeg expansion, main analysis jpeg_analysisinit jpeg analysis library initialization jpeg_analysis jpeg analysis, main 2.7.1 compression (1) jpeg_compressinit classification compression (1/2) function name jpeg_compressinit outline initializes jpeg compression library. syntax #include jpeg.h void jpeg_compressinit (jpeginfo* cinfo ) argument argument type explanation cinfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value none description initializes the jpeg compression library and sets a compression executable status. for an explanation of how to set the members of cinfo , see section 2.5.1 .
78 m sap703000-b03 user's manual (2) jpeg_compress classification compression (2/2) function name jpeg_compress outline compression, main syntax #include jpeg.h long jpeg_compress (jpeginfo* cinfo ) argument argument type explanation cinfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value error code error code explanation jpeg_ok normal termination jpeg_cont continue jpeg_err abnormal termination for details, see figure 2-1 . error details are stored in member errorstate of cinfo when processing terminates abnormally. description performs jpeg compression specified by cinfo . for an explanation of how to set the members of cinfo , see section 2.5.1 . the value stored in member errorstate of cinfo is as follows: value meaning 0x00000001 area specification for compressed image is undefined. 0x00000002 sampling ratio at which compression cannot be executed is specified (if compression of a jpeg file has been executed at 4:2:2 even though link was executed with library for compression at 4:2:2 not specified). 0x00000005 the values of tc and tp of the dht header are undefined.
79 chapter 2 library specifications 2.7.2 expansion (1) jpeg_decompressinit classification expansion (1/2) function name jpeg_decompressinit outline initializes jpeg expansion library. syntax #include jpeg.h void jpeg_decompressinit (jpeginfo* dinfo ) argument argument type explanation dinfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value none description initializes the jpeg expansion library and sets the expansion executable status. for an explanation of how to set the members of dinfo , see section 2.5.1 . (2) jpeg_decompress classification expansion (2/2) function name jpeg_decompress outline expansion, main syntax #include jpeg.h long jpeg_decompress (jpeginfo* dinfo ) argument argument type explanation dinfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value error code error code explanation jpeg_ok normal termination jpeg_cont continue jpeg_err abnormal termination for details, see figure 2-3 . error details are stored in member errorstate of dinfo when processing terminates abnormally.
80 m sap703000-b03 user's manual description executes the jpeg expansion specified by dinfo . for an explanation of how to set the members of dinfo , see section 2.5.1 . the value stored in member errorstate of dinfo is as follows: value meaning 0x00000001 area specification for expanded image is undefined. 0x00000002 sampling ratio at which expansion cannot be executed has been specified (if expansion of a jpeg file has been executed at 4:2:2 even though link was executed with expansion library at 4:2:2 not specified). 0x00000003 value of pq of dqt header is not set to 0. 0x00000004 quantization table number (tp) of dqt header is other than 0, 1, 2, or 3. 0x00000005 values of tc and tp of dht header are undefined. 0x00000006 number of components of sos header is other than 3. 0x00000007 huffman table number specified by sos header is incorrect. 0x00000008 value of ss of sos header is other than 0. 0x00000009 value of se of sos header is other than 63. 0x0000000a values of ah and al of sos header are other than 0. 0x0000000b value other than 8 is set for p of sof header. 0x0000000c value of nf of sof header is too great. 0x0000000d unknown marker appears. 0x0000000e rstn marker is illegal.
81 chapter 2 library specifications 2.7.3 analysis (1) jpeg_analysisinit classification analysis (1/2) function name jpeg_analysisinit outline initializes jpeg analysis library. syntax #include jpeg.h void jpeg_analysisinit (jpeginfo* ainfo ) argument argument type explanation ainfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value none description initializes the jpeg analysis library and sets an analysis executable status. for an explanation of how to set the members of ainfo , see section 2.5.1 . (2) jpeg_analysis classification analysis (2/2) function name jpeg_analysis outline analysis, main syntax #include jpeg.h long jpeg_analysis (jpeginfo* ainfo ) argument argument type explanation ainfo jpeginfo* pointer to jpeginfo structure note note for details of the jpeginfo structure, see section 2.5.1 . return value error code error code explanation jpeg_ok normal termination jpeg_cont continue jpeg_err abnormal termination for details, see figure 2-5 . error details are stored in member errorstate of ainfo when processing terminates abnormally.
82 m sap703000-b03 user's manual description executes the jpeg analysis specified by ainfo . for an explanation of how to set the members of ainfo , see section 2.5.1 . the value stored in member errorstate of ainfo is as follows: value meaning 0x00000006 number of components of sos header is other than 3. 0x00000007 huffman table number specified by sos header is incorrect. 0x00000008 value of ss of sos header is other than 0. 0x00000009 value of se of sos header is other than 63. 0x0000000a values of ah and al of sos header are other than 0. 0x0000000b value other than 8 is set in p of sof header. 0x0000000c value of nf of sof header is too great. 0x0000000d unknown marker has appeared.
83 chapter 2 library specifications 2.8 details of section table 2-28 lists the sections defined (used) by the library. table 2-28. sections used by library classification section name type explanation compression .jpctext text text for compression .jpctbl rodata table data for compression .jpcdata data data having initial value for compression .jpcbss bss data having no initial value for compression expansion .jpdtext text text for expansion .jpdtbl rodata table data for expansion .jpddata data data having initial value for expansion .jpdbss bss data having no initial value for expansion analysis .jpatext text text for analysis .jpatbl rodata table data for analysis .jpadata data data having initial value for analysis .jpabss bss data having no initial value for analysis common processing .jpjtext text text for common processing .jpjtbl rodata table data for common processing .jpjdata data data having initial value for common processing .jpjbss bss data having no initial value for common processing
84 m sap703000-b03 user's manual 2.9 selecting a library table 2-29 lists those files available as libraries. table 2-29. file names of libraries classification file name explanation select compression libjpegc.a compression base note 1 libjcs11.a sampling ratio 4:4:4 [h:v = 1:1] supported note 2 libjcs21.a sampling ratio 4:2:2 [h:v = 2:1] supported libjcs22.a sampling ratio 4:1:1 [h:v = 2:2] supported libjcs41.a sampling ratio 4:1:1 [h:v = 4:1] supported libjcy.a ycbcr supported note 3 libjcr.a rgb supported expansion libjpegd.a expansion base note 4 libjds11.a sampling ratio 4:4:4 [h:v = 1:1] supported note 2 libjds21.a sampling ratio 4:2:2 [h:v = 2:1] supported libjds22.a sampling ratio 4:1:1 [h:v = 2:2] supported libjds41.a sampling ratio 4:1:1 [h:v = 4:1] supported libjdhb.a huffman branch mode supported note 5 libjdhl.a huffman loop mode supported libjdy.a ycbcr supported note 6 libjdr.a rgb supported analysis libjpega.a analysis base note 7 common processing libjpeg.a common processing note 8 notes 1. this must be selected when using the compression library. 2. select a supported sampling ratio. 3. either of these must be selected when using the default jpeg_getmcu_ xx library. 4. this must be selected when using the expansion library. 5. one of these must be selected. 6. either of these must be selected when using the default jpeg_putmcu_ xx library. 7. this must be selected when using the analysis library. 8. this must be selected when using the jpeg library.
85 chapter 2 library specifications 2.9.1 selecting a library during link the following three items allow the user to select a library during link. ? non-link of unnecessary object ? selection of ycbcr/rgb of vram ? selection of huffman expansion routine to be used use the following command to select a library: jpegarce.exe: for dos jpegarc: for sun4 tm caution for dos, execute the command from the command line, not from within windows. when this function is executed, file archive is created. if a file having the same name already exists, that file is overwritten. this file is in the make file and is referenced during linking. (1) non-link of unnecessary object when the command that creates file archive is executed, the following messages are displayed. unnecessary objects are not linked if you enter data in response to these messages in sequence. do you need jpeg compress library? (y/n) . . . do you need 4:2:2 compress library? (y/n) . . . do you need 4:4:4 compress library? (y/n) . . . for example, where only a sampling ratio of 4:2:2 is required, the archive file related to the sampling ratios is selected as follows: selected file libjcs21.a, libjds21.a file not selected libjcs11.a, libjcs22.a, libjcs41.a, libjds11.a, libjds22.a, libjds41.a
86 m sap703000-b03 user's manual (2) whether to use the default vram access function the following message is displayed. input y or n in response. do you need default vram access library? (y/n) entering y causes the following message to appear. select the necessary item. please enter vram type rgb or ycbcr? (y/r) if the default vram access function is not used, the user must create the following functions: ? compression: jpeg_getmcu_22, jpeg_getmcu_41, jpeg_getmcu_21, jpeg_getmcu_11 ? expansion: jpeg_putmcu_22, jpeg_putmcu_41, jpeg_putmcu_21, jpeg_putmcu_11 for details, see section 2.10 . (3) selecting the huffman expansion routine to be used for huffman expansion, the following message is displayed. select l or b as appropriate. choose which huffman routine do you use, loop or branch? (l/b) the following archive file will be selected: ? loop: libjdhl.a ? branch: libjdhb.a
87 chapter 2 library specifications 2.9.2 specifying an archive file when the command that specifies the creation of an archive file is executed, file archive is created. this command passes the contents of the file, in @archive format to the argument of the linker in the make file. for details of the options, refer to the manual supplied with the linker. figure 2-14. specifying archiver make file . . . id850 -o $@ -d dfile $ (obj) @archive ; nec version ix -o $@ $ (obj) @archive ; ghs version libjpegc.a libjcs22.a libjcy.a libjpegd.a libjds22.a libjdhb.a libjdy.a libjpeg.a archive specification file "archive" . . .
88 m sap703000-b03 user's manual archive file libjpeg.a contains a default library. always specify libjpeg.a at the end of an archive specification file. the linker searches for a specified archive file if an unresolved symbol exists in the object. when a symbol is found, the object file including the symbol is extracted from the archive file and linked. figure 2-15. handling of archive file by linker objects linker specified archive files searches for unresolved symbol object including found symbol is linked.
89 chapter 2 library specifications 2.10 customize this section explains how the user can create vram access functions without using the default values. ap703000-b03 provides getmcu.c and putmcu.c, which are used as samples when the user creates vram access functions. 2.10.1 vram access function used during compression the functions required for vram access during compression are as follows: table 2-30. vram access functions required during compression function name supported sampling ratio jpeg_getmcu_22 4:1:1 [h:v = 2:2] jpeg_getmcu_41 4:1:1 [h:v = 4:1] jpeg_getmcu_21 4:2:2 jpeg_getmcu_11 4:4:4 these functions read data from vram in mcu units, convert the format of the data into ycbcr format, and store the data into the mcu buffer in a specific format. the functions corresponding to unnecessary sampling ratios need not be created. the user may not arbitrarily specify function names. instead, the same function names as those listed in this table must be used. the specifications of each function are as shown below. function name jpeg_getmcu_xx (xx = 22, 41, 21, 11) outline exchanges/transfers data from vram to mcu buffer. syntax #include jpeg.h void jpeg_getmcu_22 (jpeginfo* cinfo ) void jpeg_getmcu_41 (jpeginfo* cinfo ) void jpeg_getmcu_21 (jpeginfo* cinfo ) void jpeg_getmcu_11 (jpeginfo* cinfo ) argument first address of jpeginfo structure return value none description exchanges or transfers the data of the vram coordinates, specified by cinfo members currentx and currenty, to the mcu buffer specified by cinfo member mcu_buff_bptr. caution ensure that the contents of registers r20, r21, and r29 are not lost.
90 m sap703000-b03 user's manual the size of one mcu corresponding to each sampling ratio is as shown in figure 2-12. if the vram is of rgb type each pixel, converted into ycbcr format, corresponds to the figure. store data in the mcu buffer in the format shown in figure 2-11. the following information is required by this function. jpeginfo->mcu_buff_bptr first address of mcu buffer jpeginfo->currentx x coordinate of corresponding mcu jpeginfo->currenty y coordinate of corresponding mcu if 16-bit displacement of the load/store instruction is used when this routine is described in assembler, the processing speed can be increased. suppose the following is executed: *mcu=y0; *(mcu+1) = y1; *(mcu+2) = y2; *(mcu+3) = y3; at this time, the following are stored into the registers: r7 mcu r10 y0 r11 y1 r12 y2 r13 y3 if the following description is made, the amount of address calculation is substantially reduced, resulting in a higher processing speed. st.h r10, 0x0 [r7] st.h r11, 0x2 [r7] st.h r12, 0x4 [r7] st.h r13, 0x6 [r7] define the value of the symbol in an assembler file as follows (same as #define of c in the case of the ghs version). vram_gap1 .set 1 address difference between y and cb of same pixel of vram vram_gap2 .set 2 address difference between y and cr of same pixel of vram
91 chapter 2 library specifications assuming that the address of the y component of the pixel of vram to be accessed is in r8, execute the instruction as follows: ld.b 0x0 [r8], r10 ld.b vram_gap1 [r8], r11 ld.b vram_gap2 [r8], r12 andi 0xff, r10, r10 andi 0xff, r11, r11 andi 0xff, r12, r12 as a result, the following are stored into the registers. r10 value of y component r11 value of cb component r12 value of cr component 2.10.2 vram access function used during expansion the functions required for vram access during expansion are as follows: table 2-31. vram access functions required during expansion function name supported sampling ratio jpeg_putmcu_22 4:1:1 [h:v = 2:2] jpeg_putmcu_41 4:1:1 [h:v = 4:1] jpeg_putmcu_21 4:2:2 jpeg_putmcu_11 4:4:4 these functions write ycbcr-format data, stored in the mcu buffer in a specific format, to vram. the functions corresponding to unnecessary sampling ratios need not be created. the user may not arbitrarily determine the function names. instead, the same function names as those listed in this table must be used. the specifications of each function are as shown below. function name jpeg_putmcu_xx (xx = 22, 41, 21, 11) outline exchanges and transfers data from the mcu buffer to vram. syntax #include jpeg.h void jpeg_putmcu_22 (jpeginfo* dinfo ) void jpeg_putmcu_41 (jpeginfo* dinfo ) void jpeg_putmcu_21 (jpeginfo* dinfo ) void jpeg_putmcu_11 (jpeginfo* dinfo )
92 m sap703000-b03 user's manual argument first address of jpeginfo structure return value none description exchanges the data of the mcu buffer specified in dinfo member mcu_buff_bptr into data for vram, and transfers the data to the vram coordinates specified by dinfo member currentx and currenty. caution ensure that the contents of registers r20, r21, and r29 are not lost. the format in which data is stored into the mcu is shown in figure 2-11. the size of one mcu corresponding to each sampling ratio is shown in figure 2-12. if the vram is of rgb type each pixel, converted into ycbcr format, corresponds to the figure. the following information is required for this function. jpeginfo->mcu_buff_bptr first address of mcu buffer jpeginfo->currentx x coordinate of corresponding mcu jpeginfo->currenty y coordinate of corresponding mcu 2.11 symbol name convention the names of the symbols used in the jpeg library are determined according to the following convention. when you define symbols in an application, ensure that the same symbol names are not used. table 2-32. symbol name convention classification convention function prefixes jpeg_. variable prefixes jpeg_. data type jpeginfo appinfo constant jpeg_ok jpeg_err jpeg_cont sample11 sample21 sample22 sample41


▲Up To Search▲   

 
Price & Availability of SAP70300-B03

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X